<?php

use Fisharebest\Webtrees\Http\RequestHandlers\AddSpouseToFamilyPage;
use Fisharebest\Webtrees\I18N;

?>
<div class="d-flex">
    <div class="align-self-center">
        <div class="d-flex">
            <div class="wt-chart-horizontal-spacer">
                <div class="wt-chart-horizontal-first-parent"></div>
            </div>

            <div class="align-self-center">
                <?php if ($family->husband()) : ?>
                    <?= view('chart-box', ['individual' => $family->husband()]) ?>
                <?php else : ?>
                <div class="wt-chart-box">
                    <?php if ($family->canEdit()) : ?>
                        <a class="btn btn-link" href="<?= e(route(AddSpouseToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'HUSB'])) ?>">
                            <?= I18N::translate('Add a husband')?>
                        </a>
                    <?php endif ?>
                </div>
                <?php endif ?>
            </div>

            <?= view('family-page-grandparents', ['family' => $family->husband() ? $family->husband()->childFamilies()->first() : null, 'individual' => $family->husband()]) ?>
        </div>

        <div class="d-flex">
            <div class="wt-chart-horizontal-spacer">
                <div class="wt-chart-horizontal-last-parent"></div>
            </div>

            <div class="align-self-center">
                <?php if ($family->wife()) : ?>
                    <?= view('chart-box', ['individual' => $family->wife()]) ?>
                <?php else : ?>
                    <div class="wt-chart-box">
                        <?php if ($family->canEdit()) : ?>
                            <a class="btn btn-link" href="<?= e(route(AddSpouseToFamilyPage::class, ['tree' => $family->tree()->name(), 'xref' => $family->xref(), 'famtag' => 'WIFE'])) ?>">
                                <?= I18N::translate('Add a wife')?>
                            </a>
                        <?php endif ?>
                    </div>
                <?php endif ?>
            </div>

            <?= view('family-page-grandparents', ['family' => $family->wife() ? $family->wife()->childFamilies()->first() : null, 'individual' => $family->wife()]) ?>
        </div>
    </div>
</div>

